package com.lagou;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 3:57 下午 2021/11/15
 */
@Component
public class MyServlet implements ApplicationContextAware {
    private static ApplicationContext context;

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }


    //返回一个DispatcherServlet的实例
    public static DispatcherServlet getDispatcherServlet() {
        return  new DispatcherServlet((WebApplicationContext) context);

    }
}
